Repository navigation
Conversation
|
Code generated with: |
There was a problem hiding this comment.
🟡 Changes recommended
HQC static-memory bucket sizing can break key generation and decapsulation, while benchmark error handling and test cleanup can use uninitialized state or skip required teardown.
4 open issues
What changed in this PR
Adds experimental HQC v5.1 support to wolfCrypt, with an ML-KEM-style API and explicit opt-in configuration.
Changes:
- Integrates HQC parameter sets, build options, CPU dispatch, and benchmarks.
- Adds known-answer, API, error-correction, and fault-injection tests.
- Documents HQC and corrects MSVC assembly constant-table reads.
| File | Description |
|---|---|
| wolfssl/wolfcrypt/wc_hqc.h | Defines HQC parameters and public API. |
| wolfssl/wolfcrypt/memory.h | Adds larger HQC memory buckets. |
| wolfssl/wolfcrypt/include.am | Installs the HQC header. |
| wolfssl/wolfcrypt/cpuid.h | Defines additional CPU feature flags. |
| wolfssl.vcxproj | Adds HQC Windows build inputs. |
| wolfssl-VS2022.vcxproj | Adds HQC VS2022 build inputs. |
| wolfcrypt/test/test.h | Declares HQC self-tests. |
| wolfcrypt/test/test.c | Adds HQC known-answer and CPU-path tests. |
| wolfcrypt/src/sha3_asm.S | Enables parallel Keccak for HQC. |
| wolfcrypt/src/sha3_asm.asm | Enables parallel Keccak in MSVC builds. |
| wolfcrypt/src/include.am | Distributes HQC MSVC assembly. |
| wolfcrypt/src/fe_x25519_asm.asm | Corrects X25519 constant-table reads. |
| wolfcrypt/src/cpuid.c | Detects HQC acceleration features. |
| wolfcrypt/src/aes_x86_64_asm.asm | Corrects AES counter-table reads. |
| wolfcrypt/src/aes_gcm_asm.asm | Corrects AES-GCM-SIV table reads. |
| wolfcrypt/benchmark/benchmark.h | Declares HQC benchmarks. |
| wolfcrypt/benchmark/benchmark.c | Adds HQC benchmark options and routines. |
| tests/unit-mcdc/test_wc_hqc_whitebox.c | Tests Reed-Solomon error correction. |
| tests/unit-mcdc/test_hqc_fault_whitebox.c | Tests allocation and hashing failures. |
| tests/unit-mcdc/smoke-expected.txt | Registers HQC white-box tests. |
| tests/include.am | Distributes HQC white-box tests. |
| tests/api/test_hqc.h | Declares HQC API tests. |
| tests/api/test_hqc.c | Tests HQC API behavior. |
| tests/api/include.am | Builds and distributes API tests. |
| tests/api.c | Registers HQC test cases. |
| src/include.am | Adds conditional HQC library sources. |
| linuxkm/module_exports.c.template | Includes HQC declarations for exports. |
| linuxkm/Kbuild | Configures HQC kernel assembly builds. |
| doc/dox_comments/header_files/wc_hqc.h | Documents the English HQC API. |
| doc/dox_comments/header_files/doxygen_groups.h | Adds the English HQC group. |
| doc/dox_comments/header_files-ja/wc_hqc.h | Documents the Japanese HQC API. |
| doc/dox_comments/header_files-ja/doxygen_groups.h | Adds the Japanese HQC group. |
| doc/ASM_AND_MATH_DEFINES.md | Lists HQC Intel acceleration. |
| doc/ALGORITHM_DEFINES.md | Documents HQC configuration options. |
| configure.ac | Adds experimental HQC configuration. |
| CMakeLists.txt | Adds HQC options and API tests. |
| cmake/options.h.in | Publishes HQC feature defines. |
| cmake/functions.cmake | Selects HQC library sources. |
| ChangeLog.md | Records experimental HQC support. |
| .wolfssl_known_macro_extras | Registers new supported macros. |
| .github/workflows/whitebox-smoke.yml | Runs dedicated HQC white-box checks. |
| .github/configs/pq-all.json | Adds HQC configuration coverage. |
Review effort: Balanced
|
ca20886 to
1ef8d6c
Compare
|
@claude review |
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs. It adds about 66k lines of new post-quantum crypto (a portable C core plus two x86_64 assembly files of about 28k lines each) and also changes existing AES-GCM-SIV and X25519 MSVC assembly, so a human look would still be worthwhile.
What was reviewed:
- The memory.h static-memory changes: with HQC enabled, WOLFMEM_BUCKETS and WOLFMEM_DIST both have 9 entries, and the largest bucket (131072) holds HQC's workspaces of up to 43 KB.
- The regenerated MSVC assembly: the AES-GCM-SIV counter loads now read
L_aes_gcmsiv_ctr_inc_*directly instead of theptr_slot next to it. This changes behavior in existing Windows code, not only in HQC. - Not done: the KATs and the per-CPU-path tests were not run as part of this review, and neither assembly file was checked instruction by instruction.
Extended reasoning...
The change adds the HQC KEM to wolfCrypt: wc_hqc.c, wc_hqc_asm.S/.asm, CPUID detection for PCLMULQDQ, VPCLMULQDQ and GFNI, sha3 asm guard changes, memory.h bucket sizing, and build, test and documentation integration across 45 files. It is security-sensitive cryptographic code whose constant-time behavior can't be fully confirmed by reading the code. It also changes existing AES-GCM-SIV and X25519 Windows assembly, which affects builds that don't enable HQC. The size, the crypto surface and four Copilot threads that only the author resolved led to deferring rather than approving.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12394
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): .github/configs/pq-all.json, .github/workflows/whitebox-smoke.yml, .wolfssl_known_macro_extras, CMakeLists.txt, ChangeLog.md, cmake/functions.cmake, cmake/options.h.in, configure.ac, doc/ALGORITHM_DEFINES.md, doc/ASM_AND_MATH_DEFINES.md, doc/dox_comments/header_files-ja/doxygen_groups.h, doc/dox_comments/header_files-ja/wc_hqc.h, doc/dox_comments/header_files/doxygen_groups.h, doc/dox_comments/header_files/wc_hqc.h, linuxkm/Kbuild, linuxkm/module_exports.c.template, src/include.am, tests/api/include.am, tests/api/test_hqc.h, tests/include.am and 15 more
Coverage: 9 of 10 in-scope changed file(s) opened by the reviewer; not opened: tests/api.c
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
There was a problem hiding this comment.
🟡 Changes recommended
Active issues leave an out-of-bounds test write after SHAKE initialization failure and allow benchmark cleanup to invoke a device callback on uninitialized SHAKE state.
2 open issues
1 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
The test wrappers can break compilation or linking in HQC-disabled configurations, and the INTIME SDK header-copy list omits the newly required wc_hqc.h header.
2 open issues
2 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
The security-critical KEM and assembly changes require specialist review and cross-CPU Windows validation for constant-time behavior and interoperability not established by the supplied evidence.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
|
@claude review |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12394
Scan targets checked: wolfssl-src, wolfssl-bugs
Unchanged since last review (not re-run): wolfcrypt-src, wolfcrypt-bugs
Not reviewed (no scan target covers them): .github/configs/pq-all.json, .github/workflows/whitebox-smoke.yml, .wolfssl_known_macro_extras, CMakeLists.txt, ChangeLog.md, IDE/INTIME-RTOS/Makefile, cmake/functions.cmake, cmake/options.h.in, configure.ac, doc/ALGORITHM_DEFINES.md, doc/ASM_AND_MATH_DEFINES.md, doc/dox_comments/header_files-ja/doxygen_groups.h, doc/dox_comments/header_files-ja/wc_hqc.h, doc/dox_comments/header_files/doxygen_groups.h, doc/dox_comments/header_files/wc_hqc.h, linuxkm/Kbuild, linuxkm/module_exports.c.template, src/include.am, tests/api/include.am, tests/api/test_hqc.h and 16 more
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: tests/unit-mcdc/test_hqc_fault_whitebox.c
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
Implement HQC-1, HQC-3 and HQC-5 (HQC specification v5.1) with an API like ML-KEM's: wc_HqcKey_* for key generation, encapsulation, decapsulation and encoding/decoding. HQC is experimental: it is built only with --enable-experimental --enable-hqc[=options], never by --enable-all. - wc_hqc.c: constant-time portable C, with build options for size and speed (small, small-mem, cache-h, lazy-hek, no-cache-y, ...) and for compiling out key generation, encapsulation or decapsulation. - wc_hqc_asm.S/.asm: x86_64 assembly (PCLMULQDQ, VPCLMULQDQ, AVX2, AVX-512, GFNI, BMI), chosen at run time from CPU features. Encapsulation and decapsulation run several SHAKE sponges together on the 4-way and 8-way Keccak assembly. - cpuid: detect PCLMULQDQ, VPCLMULQDQ and GFNI. - Regenerated MSVC assembly: an element of a constant table is now read from the table, not from the pointer next to it (AES, AES-GCM, X25519). - Build: configure, CMake, Visual Studio projects, linuxkm. - Tests: known-answer tests repeated on each CPU path in testwolfcrypt, API tests, Reed-Solomon and fault-injection white-boxes, pq-all CI configs and a white-box CI step. - Benchmark: -hqc, with all-zero seeds without an RNG or with WOLFSSL_HQC_BENCH_DETERMINISTIC. - Docs: Doxygen (English and Japanese), ALGORITHM_DEFINES.md, ASM_AND_MATH_DEFINES.md, ChangeLog.


Description
Implement HQC-1, HQC-3 and HQC-5 (HQC specification v5.1) with an API like ML-KEM's: wc_HqcKey_* for key generation, encapsulation, decapsulation and encoding/decoding. HQC is experimental: it is built only with --enable-experimental --enable-hqc[=options], never by --enable-all.
Testing
./configure --disable-shared --enable-hqc --enable-experimental
./configure --disable-shared --enable-hqc --enable-experimental --enable-intelasm
--enable-hqc => lazy-hek/no-cache-y/no-cache-hek/no-make-key/no-encapsulate/no-decapsulate/small/small-mem/no-large-code/1/3/5
Generator
https://github.com/wolfSSL/scripts/pull/738